﻿#region [ Modification History ]
/*
 * 05/20/2013 Denis Kholine
 *  Generated Original version of source code.
 */
#endregion

#region  [ UIUC NCSA Open Source License ]
/*****************************************************************************\
 *             University of Illinois/NCSA Open Source License
 *
 * 
 *      Copyright © 2012,2013, The Board of Trustees of the University of Illinois. All rights reserved.
 *
 *      Developed by: Rakesh Bobba, Derek Dagit, Erich Heine, Denis Kholine,
 *                    Klara Nahrstedt, David Rodgers,   William H. Sanders, Tim Yardley
 *
 *      Information Trust Institute/Coordinated Science Laboratory
 * 
 *      University of Illinois
 *      
 *      The Board of Trustees of the University of Illinois
 *      109 Coble Hall
 *      801 South Wright Street
 *      Champaign, IL 61820-6242
 *
 *      http://www.iti.illinois.edu / http://csl.illinois.edu
 * 
 *      Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 
 *      associated documentation files (the “Software”), to deal with the Software without restriction, 
 *      including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
 *      and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
 *      subject to the following conditions:
 *
 *      Redistributions of source code must retain the above copyright notice, this list of conditions and the
 *      following disclaimers.
 *      
 *      Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
 *      the following disclaimers in the documentation and/or other materials provided with the distribution.
 *
 *      Neither the names of Information Trust institute, Coordinated Science Laboratory, University of Illinois,
 *      The Board of Trustees of the University of Illinois nor the names of its contributors may be used to 
 *      endorse or promote products derived from this Software without specific prior written permission.
 *      
 *      THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 *      LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN
 *      NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 *      WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
 *      SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
 *      
 \*****************************************************************************/
#endregion

#region [ Using ]
using System;
using SIEGate.Core;
using SIEGate.Core.Notifications;
using SIEGate.Core.MessageBusses;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using GSF.TimeSeries.Transport;
#endregion

namespace SIEGateCoreTest.AdapterContainerTests
{
    /// <summary>
    /// AdapterContainer tests
    /// Note: Input adapter stream ID's of the first adapter should match output adapter stream ID's
    /// </summary>
    [TestClass]
    public class AdapterContainerTests
    {
        #region [ Members ]
        private bool eventstatus;
        #endregion

        #region [ Context ]
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }
        #endregion

        #region [ Additional test attributes ]
        //
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestReset to run code before running each test
        [TestInitialize()]
        public void MyTestInitialize()
        {
        }
        //
        //Use TestCleanup to run code after each test has run
        [TestCleanup()]
        public void MyTestCleanup()
        { }
        //
        #endregion

        #region [ Methods]
        /// <summary>
        /// doit test        
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void doitTest()
        {
            // Guid sets
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();

            // Assign values
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));

            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();

            // processor info
            IAdapterInfo adapterinfo0 = new MockAdapter.MockAdapterInfo(incoming0, outgoing0);

            adapterinfo0.ID = (uint)1;

            adapterinfo0.Name = (String)"SimpleAdapter0";

            adapterinfo0.Receiver = signal0;

            // Create Smart Adapters
            IAdapter simpleAdapter0 = new MockAdapter(adapterinfo0);

            // Initialize target
            IMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);
            AdapterContainer target = new AdapterContainer(bus, adaptercontainerinfo);

            bool expected = true;
            bool actual = false;
            try
            {
                target.doit();
                actual = true;
            }
            catch
            {
                actual = false;
            }
            Assert.AreEqual(expected, actual);
            

        }
        /// <summary>
        /// Link Unit Test: Simple Adapter case
        /// Success conditions: should not raise errors and exists in container.
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void LinkSimpleAdapter()
        {

            // Guid sets
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();

            // Assign values
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));

            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();

            // processor info
            IAdapterInfo adapterinfo0 = new MockAdapter.MockAdapterInfo(incoming0, outgoing0);

            adapterinfo0.ID = (uint)1;

            adapterinfo0.Name = (String)"SimpleAdapter0";

            adapterinfo0.Receiver = signal0;

            // Create Smart Adapters
            IAdapter simpleAdapter0 = new MockAdapter(adapterinfo0);

            // Initialize target
            IMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);
            AdapterContainer target = new AdapterContainer(bus, adaptercontainerinfo);

        }

        /// <summary>
        /// Link Unit Test: Smart Adapter
        /// Success conditions: should not raise errors and exists in container
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void LinkSmartAdapter()
        {

            // Guid sets
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();

            // Assign values
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));


            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();

            ISmartAdapterInfo adapterinfo0 = new MockSmartAdapter.MockSmartAdapterInfo(incoming0, outgoing0);

            adapterinfo0.ID = (uint)1;

            adapterinfo0.Name = (String)"SmartAdapter0";

            adapterinfo0.Receiver = signal0;

            // Create Smart Adapters
            ISmartAdapter smartAdapter0 = new MockSmartAdapter(adapterinfo0);

            // Initialize target
            IMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);
            AdapterContainer target = new AdapterContainer(bus, adaptercontainerinfo);


        }

        /// <summary>
        /// Link Unit Test: Two simple adapters
        /// Success conditions: no errors should be raised in AdapterContainer on Link method execution
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void LinkSimplePlusSimpleAdapters()
        {
            // Two smart Adapters
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();
            ISet<Guid> incoming1 = new HashSet<Guid>();
            ISet<Guid> outgoing1 = new HashSet<Guid>();

            // Assign values
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));// join with next
            incoming1.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));
            outgoing1.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));


            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();
            INotificationReceiver signal1 = new MockINotificationReceiver();
            INotificationReceiver signal2 = new MockINotificationReceiver();

            // processor info
            IAdapterInfo adapterinfo0 = new MockAdapter.MockAdapterInfo(incoming0, outgoing0);
            IAdapterInfo adapterinfo1 = new MockAdapter.MockAdapterInfo(incoming1, outgoing1);

            adapterinfo0.ID = (uint)1;
            adapterinfo1.ID = (uint)2;

            adapterinfo0.Name = (String)"SimpleAdapter0";
            adapterinfo1.Name = (String)"SimpleAdapter1";

            adapterinfo0.Receiver = signal0;
            adapterinfo1.Receiver = signal1;

            // Create Adapters
            IAdapter simpleAdapter0 = new MockAdapter(adapterinfo0);
            IAdapter simpleAdapter1 = new MockAdapter(adapterinfo1);


            // Initialize target
            IMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);
            AdapterContainer target = new AdapterContainer(bus, adaptercontainerinfo);

            // Call link twice for simple adapters;
            target.Link(simpleAdapter1);

        }

        /// <summary>
        /// Link Unit Test: Two smart adapters 
        /// Success conditions: both static inputs set to false raise errors
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void LinkSmartPlusSmartStaticFalse()
        {
            // Two smart Adapters
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();
            ISet<Guid> incoming1 = new HashSet<Guid>();
            ISet<Guid> outgoing1 = new HashSet<Guid>();

            // Assign values
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));// join with next
            incoming1.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));
            outgoing1.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));

            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();
            INotificationReceiver signal1 = new MockINotificationReceiver();

            // processor info           
            ISmartAdapterInfo adapterinfo0 = new MockSmartAdapter.MockSmartAdapterInfo(incoming0, outgoing0);
            ISmartAdapterInfo adapterinfo1 = new MockSmartAdapter.MockSmartAdapterInfo(incoming1, outgoing1);

            adapterinfo0.ID = (uint)1;
            adapterinfo1.ID = (uint)2;

            adapterinfo0.Name = (String)"SmartAdapter0";
            adapterinfo1.Name = (String)"SmartAdapter1";

            adapterinfo0.Receiver = signal0;
            adapterinfo1.Receiver = signal1;

            // Create dapters
            ISmartAdapter smartAdapter0 = new MockSmartAdapter(adapterinfo0);
            ISmartAdapter smartAdapter1 = new MockSmartAdapter(adapterinfo1);

            // Initialize target
            IMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);
            AdapterContainer target = new AdapterContainer(bus, adaptercontainerinfo);

            // Call link 
            try
            {
                target.Link(smartAdapter1);
            }
            catch (Exception e)
            {
                Assert.IsFalse(false);
            }
        }

        /// <summary>
        /// Link Unit Test: Simple adapter plus smart adapter
        /// Success conditions: error unless smart adapter staticticinputs set to true
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void LinkSimplePlusSmartStaticTrue()
        {
            // Two smart Adapters
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();
            ISet<Guid> incoming1 = new HashSet<Guid>();
            ISet<Guid> outgoing1 = new HashSet<Guid>();

            // Assign values
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));// join with next
            incoming1.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));
            outgoing1.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));


            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();
            INotificationReceiver signal1 = new MockINotificationReceiver();
            INotificationReceiver signal2 = new MockINotificationReceiver();

            // processor info
            IAdapterInfo adapterinfo0 = new MockAdapter.MockAdapterInfo(incoming0, outgoing0);
            ISmartAdapterInfo adapterinfo1 = new MockSmartAdapter.MockSmartAdapterInfo(incoming1, outgoing1);

            // change static input property
            MockSmartAdapter.MockSmartAdapterInfo adapter1 = (MockSmartAdapter.MockSmartAdapterInfo)adapterinfo1;
            adapter1.SetStaticInputs(true);
            adapterinfo1 = (ISmartAdapterInfo)adapter1;

            adapterinfo0.ID = (uint)1;
            adapterinfo1.ID = (uint)2;

            adapterinfo0.Name = (String)"SimpleAdapter0";
            adapterinfo1.Name = (String)"SmartAdapter1";

            adapterinfo0.Receiver = signal0;
            adapterinfo1.Receiver = signal1;

            // Create Smart Adapters
            IAdapter simpleAdapter0 = new MockAdapter(adapterinfo0);
            ISmartAdapter smartAdapter1 = new MockSmartAdapter(adapterinfo1);
            //change static parmeter


            // Initialize target
            IMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);
            AdapterContainer target = new AdapterContainer(bus, adaptercontainerinfo);


            // Call link
            target.Link(smartAdapter1);
        }

        /// <summary>
        /// Link Unit Test: Simple adapter plus smart adapter
        /// Success conditions: error unless smart adapter staticticinputs set to true
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void LinkSimplePlusSmartStaticFalse()
        {
            // Two smart Adapters
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();
            ISet<Guid> incoming1 = new HashSet<Guid>();
            ISet<Guid> outgoing1 = new HashSet<Guid>();

            // Assign values
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));// join with next
            incoming1.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));
            outgoing1.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));


            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();
            INotificationReceiver signal1 = new MockINotificationReceiver();
            INotificationReceiver signal2 = new MockINotificationReceiver();

            // processor info
            IAdapterInfo adapterinfo0 = new MockAdapter.MockAdapterInfo(incoming0, outgoing0);
            ISmartAdapterInfo adapterinfo1 = new MockSmartAdapter.MockSmartAdapterInfo(incoming1, outgoing1);

            adapterinfo0.ID = (uint)1;
            adapterinfo1.ID = (uint)2;

            adapterinfo0.Name = (String)"SimpleAdapter0";
            adapterinfo1.Name = (String)"SmartAdapter1";

            adapterinfo0.Receiver = signal0;
            adapterinfo1.Receiver = signal1;

            // Create Smart Adapters
            IAdapter simpleAdapter0 = new MockAdapter(adapterinfo0);
            ISmartAdapter smartAdapter1 = new MockSmartAdapter(adapterinfo1);
            //change static parmeter


            // Initialize target
            IMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);
            AdapterContainer target = new AdapterContainer(bus, adaptercontainerinfo);


            // Call link
            try
            {
                target.Link(smartAdapter1);
            }
            catch (Exception e)
            {
                Assert.IsFalse(false);
            }
        }

        /// <summary>
        /// Link Unit Test: Smart next smart should not raise errors
        /// Success conditions: error unless smart adapter staticticinputs set to true
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void LinkSmarPlusSmartStaticTrue()
        {

            // Two smart Adapters
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();
            ISet<Guid> incoming1 = new HashSet<Guid>();
            ISet<Guid> outgoing1 = new HashSet<Guid>();

            // Assign values
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));// join with next
            incoming1.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));
            outgoing1.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));


            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();
            INotificationReceiver signal1 = new MockINotificationReceiver();

            // processor info
            ISmartAdapterInfo adapterinfo0 = new MockSmartAdapter.MockSmartAdapterInfo(incoming0, outgoing0);
            ISmartAdapterInfo adapterinfo1 = new MockSmartAdapter.MockSmartAdapterInfo(incoming1, outgoing1);

            // change static input property
            MockSmartAdapter.MockSmartAdapterInfo adapter0 = (MockSmartAdapter.MockSmartAdapterInfo)adapterinfo0;
            adapter0.SetStaticInputs(true);
            adapterinfo0 = (ISmartAdapterInfo)adapter0;

            // change static input property
            MockSmartAdapter.MockSmartAdapterInfo adapter1 = (MockSmartAdapter.MockSmartAdapterInfo)adapterinfo1;
            adapter1.SetStaticInputs(true);
            adapterinfo1 = (ISmartAdapterInfo)adapter1;

            adapterinfo0.ID = (uint)1;
            adapterinfo1.ID = (uint)2;

            adapterinfo0.Name = (String)"SmartAdapter0";
            adapterinfo1.Name = (String)"SmartAdapter1";

            adapterinfo0.Receiver = signal0;
            adapterinfo1.Receiver = signal1;

            // Create Smart Adapters
            ISmartAdapter smartAdapter0 = new MockSmartAdapter(adapterinfo0);
            ISmartAdapter smartAdapter1 = new MockSmartAdapter(adapterinfo1);

            // Initialize target
            IMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);
            AdapterContainer target = new AdapterContainer(bus, adaptercontainerinfo);

            // Call link 
            target.Link(smartAdapter1);
        }

        /// <summary>
        /// register unit test
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void registerTest()
        {
            // One smart Adapters
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();

            // Assign values
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));

            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();

            // processor info
            IAdapterInfo adapterinfo0 = new MockAdapter.MockAdapterInfo(incoming0, outgoing0);

            adapterinfo0.ID = (uint)1;

            adapterinfo0.Name = (String)"SimpleAdapter";

            adapterinfo0.Receiver = signal0;

            // Create Smart Adapters
            IAdapter simpleAdapter0 = new MockAdapter(adapterinfo0);

            // Initialize target
            IMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);
            AdapterContainer target = new AdapterContainer(bus, adaptercontainerinfo);

            target.Register();

            //bus.Subscribe(outgoing0);
            //bus.UnSubscribe(outgoing0);

        }

        /// <summary>
        /// Message bus subscription
        /// Simple Adapter
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void SubscribeSimpleAdapter()
        {

            // One smart Adapters
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();

            // Assign values. Represent first adapter in line with four inputs A,B,C,D
            // Default behaviour for smart adapter return C & D
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            incoming0.Add(Guid.Parse("9AC8D5D8-FF0F-45CA-9C40-7F2CBB8DDBB2"));
            incoming0.Add(Guid.Parse("485A6395-CD79-48FF-9D4E-38B157FD6C5C"));
            incoming0.Add(Guid.Parse("1B9C8891-9BE3-4C4C-ADCF-D4D211C5639A"));

            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));
            outgoing0.Add(Guid.Parse("25785605-1A48-4A01-88F2-04C7E9263F81"));

            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();

            // processor info
            IAdapterInfo adapterinfo0 = new MockAdapter.MockAdapterInfo(incoming0, outgoing0);

            adapterinfo0.ID = (uint)1;

            adapterinfo0.Name = (String)"SimpleAdapter";

            adapterinfo0.Receiver = signal0;

            adapterinfo0.MyInstance = new MockAdapter(adapterinfo0);

            // Create Smart Adapters
            IAdapter simpleAdapter0 = new MockAdapter(adapterinfo0);

            // Initialize target
            MockMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);
            AdapterContainer target = new AdapterContainer(bus, adaptercontainerinfo);

            ISet<Guid> subsribeto = new HashSet<Guid>();
            subsribeto.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));

            target.Register();
            bus.TriggerSubscription(subsribeto);

            // extract Guids
            int expected = 4; // all four inputs 
            int actual = bus.Subscribed.Count;

            bus.TriggerUnsubscription(subsribeto);

            // verify status
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        /// Message bus subscription:
        /// Smart Adapter 
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void SubscribeSmartAdapter()
        {

            // One smart Adapters
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();

            // Assign values. Represent first adapter in line with four inputs A,B,C,D
            // Default behaviour for smart adapter return C & D
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            incoming0.Add(Guid.Parse("9AC8D5D8-FF0F-45CA-9C40-7F2CBB8DDBB2"));
            incoming0.Add(Guid.Parse("485A6395-CD79-48FF-9D4E-38B157FD6C5C"));
            incoming0.Add(Guid.Parse("1B9C8891-9BE3-4C4C-ADCF-D4D211C5639A"));

            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));
            outgoing0.Add(Guid.Parse("25785605-1A48-4A01-88F2-04C7E9263F81"));

            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();

            // processor info
            ISmartAdapterInfo adapterinfo0 = new MockSmartAdapter.MockSmartAdapterInfo(incoming0, outgoing0);

            adapterinfo0.ID = (uint)1;

            adapterinfo0.Name = (String)"SmartAdapter";

            adapterinfo0.Receiver = signal0;

            // Create Smart Adapters
            IAdapter simpleAdapter0 = new MockSmartAdapter(adapterinfo0);

            // Initialize target
            MockMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);
            AdapterContainer target = new AdapterContainer(bus, adaptercontainerinfo);


            ISet<Guid> subsribeto = new HashSet<Guid>();
            subsribeto.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));

            target.Register();
            bus.TriggerSubscription(subsribeto);

            // extract Guids
            int expected = 1;
            int actual = bus.Subscribed.Count;

            bus.TriggerUnsubscription(subsribeto);

            // verify status
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        /// Message bus subscription
        /// Simple ->  Simple -> Smart Adapters
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void SubscribeSimpleSimpleSmartAdapters()
        {
            // Two smart Adapters
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();
            ISet<Guid> incoming1 = new HashSet<Guid>();
            ISet<Guid> outgoing1 = new HashSet<Guid>();
            ISet<Guid> incoming2 = new HashSet<Guid>();
            ISet<Guid> outgoing2 = new HashSet<Guid>();

            // Assign values. Represent first adapter in line with four inputs A,B,C,D
            // Default behaviour for smart adapter return C & D
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            incoming0.Add(Guid.Parse("9AC8D5D8-FF0F-45CA-9C40-7F2CBB8DDBB2"));
            incoming0.Add(Guid.Parse("485A6395-CD79-48FF-9D4E-38B157FD6C5C"));
            incoming0.Add(Guid.Parse("1B9C8891-9BE3-4C4C-ADCF-D4D211C5639A"));
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));// join with next

            incoming1.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));
            outgoing1.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));// join with next

            incoming2.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));
            outgoing2.Add(Guid.Parse("19E200DD-965B-4A5D-8F7A-7A3DE6003895"));
            outgoing2.Add(Guid.Parse("53EE5AF4-9560-40BA-9F85-2E586583FDEB"));

            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();
            INotificationReceiver signal1 = new MockINotificationReceiver();
            INotificationReceiver signal2 = new MockINotificationReceiver();

            // processor info
            IAdapterInfo adapterinfo0 = new MockAdapter.MockAdapterInfo(incoming0, outgoing0);
            IAdapterInfo adapterinfo1 = new MockAdapter.MockAdapterInfo(incoming1, outgoing1);
            MockSmartAdapter.MockSmartAdapterInfo adapterinfo2 = new MockSmartAdapter.MockSmartAdapterInfo(incoming2, outgoing2);

            adapterinfo2.SetStaticInputs(true);

            adapterinfo0.ID = (uint)1;
            adapterinfo1.ID = (uint)2;
            adapterinfo2.ID = (uint)3;

            adapterinfo0.Name = (String)"SimpleAdapter0";
            adapterinfo1.Name = (String)"SimpleAdapter1";
            adapterinfo2.Name = (String)"SmartAdapter2";

            adapterinfo0.Receiver = signal0;
            adapterinfo1.Receiver = signal1;
            adapterinfo2.Receiver = signal2;

            // Create Smart Adapters
            IAdapter simpleAdapter0 = new MockAdapter(adapterinfo0);
            IAdapter simpleAdapter1 = new MockAdapter(adapterinfo1);
            ISmartAdapter smartAdapter2 = new MockSmartAdapter(adapterinfo2);
            //change static parmeter 

            // Initialize target
            MockMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);
            AdapterContainer target = new AdapterContainer(bus, adaptercontainerinfo);

            // link chain
            target.Link(simpleAdapter1);
            target.Link(smartAdapter2);

            ISet<Guid> subsribeto = new HashSet<Guid>();
            subsribeto.Add(Guid.Parse("19E200DD-965B-4A5D-8F7A-7A3DE6003895"));

            // Registers events
            target.Register();
            bus.TriggerSubscription(subsribeto);

            // extract Guids
            int expected = 4; // all four inputs 
            int actual = bus.Subscribed.Count;

            bus.TriggerUnsubscription(subsribeto);

            // verify status
            Assert.AreEqual(expected, actual);



        }

        /// <summary>
        /// Message bus subscription
        /// Smart Smart Simple
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void SubscribeSmartSmartSimpleAdapters()
        {
            // Two smart Adapters
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();
            ISet<Guid> incoming1 = new HashSet<Guid>();
            ISet<Guid> outgoing1 = new HashSet<Guid>();
            ISet<Guid> incoming2 = new HashSet<Guid>();
            ISet<Guid> outgoing2 = new HashSet<Guid>();

            // Assign values. Represent first adapter in line with four inputs A,B,C,D
            // Default behaviour for smart adapter return C & D
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            incoming0.Add(Guid.Parse("9AC8D5D8-FF0F-45CA-9C40-7F2CBB8DDBB2"));
            incoming0.Add(Guid.Parse("485A6395-CD79-48FF-9D4E-38B157FD6C5C"));
            incoming0.Add(Guid.Parse("1B9C8891-9BE3-4C4C-ADCF-D4D211C5639A"));
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));// join with next

            incoming1.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));
            outgoing1.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));// join with next

            incoming2.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));
            outgoing2.Add(Guid.Parse("19E200DD-965B-4A5D-8F7A-7A3DE6003895"));
            outgoing2.Add(Guid.Parse("53EE5AF4-9560-40BA-9F85-2E586583FDEB"));

            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();
            INotificationReceiver signal1 = new MockINotificationReceiver();
            INotificationReceiver signal2 = new MockINotificationReceiver();

            // processor info
            MockSmartAdapter.MockSmartAdapterInfo adapterinfo0 = new MockSmartAdapter.MockSmartAdapterInfo(incoming0, outgoing0);
            MockSmartAdapter.MockSmartAdapterInfo adapterinfo1 = new MockSmartAdapter.MockSmartAdapterInfo(incoming1, outgoing1);
            IAdapterInfo adapterinfo2 = new MockAdapter.MockAdapterInfo(incoming2, outgoing2);

            adapterinfo0.SetStaticInputs(true);
            adapterinfo1.SetStaticInputs(true);

            adapterinfo0.ID = (uint)1;
            adapterinfo1.ID = (uint)2;
            adapterinfo2.ID = (uint)3;

            adapterinfo0.Name = (String)"SmartAdapter0";
            adapterinfo1.Name = (String)"SmartAdapter1";
            adapterinfo2.Name = (String)"SimpleAdapter2";

            adapterinfo0.Receiver = signal0;
            adapterinfo1.Receiver = signal1;
            adapterinfo2.Receiver = signal2;

            // Create Smart Adapters
            ISmartAdapter smartAdapter0 = new MockSmartAdapter(adapterinfo0);
            ISmartAdapter smartAdapter1 = new MockSmartAdapter(adapterinfo1);
            IAdapter simpleAdapter2 = new MockAdapter(adapterinfo2);

            // Initialize target
            MockMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);
            AdapterContainer target = new AdapterContainer(bus, adaptercontainerinfo);

            // link chain
            target.Link(smartAdapter1);
            target.Link(simpleAdapter2);

            ISet<Guid> subsribeto = new HashSet<Guid>();
            subsribeto.Add(Guid.Parse("19E200DD-965B-4A5D-8F7A-7A3DE6003895"));

            // Registers events
            target.Register();
            bus.TriggerSubscription(subsribeto);

            // extract Guids
            int expected = 4; // all four inputs 
            int actual = bus.Subscribed.Count;

            bus.TriggerUnsubscription(subsribeto);

            // verify status
            Assert.AreEqual(expected, actual);

        }

        /// <summary>
        /// Message bus subscription
        /// Simple Smart Smart Adapters
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void SubscribeSimpleSmartSmartAdapters()
        {
            // Two smart Adapters
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();
            ISet<Guid> incoming1 = new HashSet<Guid>();
            ISet<Guid> outgoing1 = new HashSet<Guid>();
            ISet<Guid> incoming2 = new HashSet<Guid>();
            ISet<Guid> outgoing2 = new HashSet<Guid>();

            // Assign values. Represent first adapter in line with four inputs A,B,C,D
            // Default behaviour for smart adapter return C & D
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            incoming0.Add(Guid.Parse("9AC8D5D8-FF0F-45CA-9C40-7F2CBB8DDBB2"));
            incoming0.Add(Guid.Parse("485A6395-CD79-48FF-9D4E-38B157FD6C5C"));
            incoming0.Add(Guid.Parse("1B9C8891-9BE3-4C4C-ADCF-D4D211C5639A"));
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));// join with next

            incoming1.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));
            outgoing1.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));// join with next

            incoming2.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));
            outgoing2.Add(Guid.Parse("19E200DD-965B-4A5D-8F7A-7A3DE6003895"));
            outgoing2.Add(Guid.Parse("53EE5AF4-9560-40BA-9F85-2E586583FDEB"));

            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();
            INotificationReceiver signal1 = new MockINotificationReceiver();
            INotificationReceiver signal2 = new MockINotificationReceiver();

            // processor info
            IAdapterInfo adapterinfo0 = new MockAdapter.MockAdapterInfo(incoming0, outgoing0);
            MockSmartAdapter.MockSmartAdapterInfo adapterinfo1 = new MockSmartAdapter.MockSmartAdapterInfo(incoming1, outgoing1);
            MockSmartAdapter.MockSmartAdapterInfo adapterinfo2 = new MockSmartAdapter.MockSmartAdapterInfo(incoming2, outgoing2);

            adapterinfo1.SetStaticInputs(true);
            adapterinfo2.SetStaticInputs(true);

            adapterinfo0.ID = (uint)1;
            adapterinfo1.ID = (uint)2;
            adapterinfo2.ID = (uint)3;

            adapterinfo0.Name = (String)"SimpleAdapter0";
            adapterinfo1.Name = (String)"SmartAdapter1";
            adapterinfo2.Name = (String)"SmartAdapter2";

            adapterinfo0.Receiver = signal0;
            adapterinfo1.Receiver = signal1;
            adapterinfo2.Receiver = signal2;

            // Create Smart Adapters
            IAdapter smartAdapter0 = new MockAdapter(adapterinfo0);
            ISmartAdapter smartAdapter1 = new MockSmartAdapter(adapterinfo1);
            ISmartAdapter simpleAdapter2 = new MockSmartAdapter(adapterinfo2);

            // Initialize target
            MockMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);
            AdapterContainer target = new AdapterContainer(bus, adaptercontainerinfo);

            // link chain
            target.Link(smartAdapter1);
            target.Link(simpleAdapter2);

            ISet<Guid> subsribeto = new HashSet<Guid>();
            subsribeto.Add(Guid.Parse("19E200DD-965B-4A5D-8F7A-7A3DE6003895"));

            // Registers events
            target.Register();
            bus.TriggerSubscription(subsribeto);

            // extract Guids
            int expected = 4; // all four inputs 
            int actual = bus.Subscribed.Count;

            bus.TriggerUnsubscription(subsribeto);

            // verify status
            Assert.AreEqual(expected, actual);

        }

        /// <summary>
        /// Message bus subscription
        /// Smart Smart Smart Adapters
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void SubscribeSmartSmartSmartAdapters()
        {
            // Two smart Adapters
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();
            ISet<Guid> incoming1 = new HashSet<Guid>();
            ISet<Guid> outgoing1 = new HashSet<Guid>();
            ISet<Guid> incoming2 = new HashSet<Guid>();
            ISet<Guid> outgoing2 = new HashSet<Guid>();

            // Assign values. Represent first adapter in line with four inputs A,B,C,D
            // Default behaviour for smart adapter return C & D
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            incoming0.Add(Guid.Parse("9AC8D5D8-FF0F-45CA-9C40-7F2CBB8DDBB2"));
            incoming0.Add(Guid.Parse("485A6395-CD79-48FF-9D4E-38B157FD6C5C"));
            incoming0.Add(Guid.Parse("1B9C8891-9BE3-4C4C-ADCF-D4D211C5639A"));
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));// join with next

            incoming1.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));
            outgoing1.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));// join with next

            incoming2.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));
            outgoing2.Add(Guid.Parse("19E200DD-965B-4A5D-8F7A-7A3DE6003895"));
            outgoing2.Add(Guid.Parse("53EE5AF4-9560-40BA-9F85-2E586583FDEB"));

            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();
            INotificationReceiver signal1 = new MockINotificationReceiver();
            INotificationReceiver signal2 = new MockINotificationReceiver();

            // processor info
            MockSmartAdapter.MockSmartAdapterInfo adapterinfo0 = new MockSmartAdapter.MockSmartAdapterInfo(incoming0, outgoing0);
            MockSmartAdapter.MockSmartAdapterInfo adapterinfo1 = new MockSmartAdapter.MockSmartAdapterInfo(incoming1, outgoing1);
            MockSmartAdapter.MockSmartAdapterInfo adapterinfo2 = new MockSmartAdapter.MockSmartAdapterInfo(incoming2, outgoing2);

            adapterinfo0.SetStaticInputs(true);
            adapterinfo1.SetStaticInputs(true);
            adapterinfo2.SetStaticInputs(true);


            adapterinfo0.ID = (uint)1;
            adapterinfo1.ID = (uint)2;
            adapterinfo2.ID = (uint)3;

            adapterinfo0.Name = (String)"SmartAdapter0";
            adapterinfo1.Name = (String)"SmartAdapter1";
            adapterinfo2.Name = (String)"SmartAdapter2";

            adapterinfo0.Receiver = signal0;
            adapterinfo1.Receiver = signal1;
            adapterinfo2.Receiver = signal2;

            // Create Smart Adapters
            ISmartAdapter smartAdapter0 = new MockSmartAdapter(adapterinfo0);
            ISmartAdapter smartAdapter1 = new MockSmartAdapter(adapterinfo1);
            ISmartAdapter smartAdapter2 = new MockSmartAdapter(adapterinfo2);

            // Initialize target
            MockMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);
            AdapterContainer target = new AdapterContainer(bus, adaptercontainerinfo);

            // link chain
            target.Link(smartAdapter1);
            target.Link(smartAdapter2);

            ISet<Guid> subsribeto = new HashSet<Guid>();
            subsribeto.Add(Guid.Parse("19E200DD-965B-4A5D-8F7A-7A3DE6003895"));

            // Registers events 
            target.Register();
            bus.TriggerSubscription(subsribeto);

            // extract Guids
            int expected = 1; // all four inputs 
            int actual = bus.Subscribed.Count;

            bus.TriggerUnsubscription(subsribeto);

            // verify status
            Assert.AreEqual(expected, actual);

        }

        /// <summary>
        /// Message bus subscription
        /// Smart SmartStatic Smart Adapters
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void SubscribeSmartFalseSmartSmartAdapters()
        {
            // Two smart Adapters
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();
            ISet<Guid> incoming1 = new HashSet<Guid>();
            ISet<Guid> outgoing1 = new HashSet<Guid>();
            ISet<Guid> incoming2 = new HashSet<Guid>();
            ISet<Guid> outgoing2 = new HashSet<Guid>();

            // Assign values. Represent first adapter in line with four inputs A,B,C,D
            // Default behaviour for smart adapter return C & D
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            incoming0.Add(Guid.Parse("9AC8D5D8-FF0F-45CA-9C40-7F2CBB8DDBB2"));
            incoming0.Add(Guid.Parse("485A6395-CD79-48FF-9D4E-38B157FD6C5C"));
            incoming0.Add(Guid.Parse("1B9C8891-9BE3-4C4C-ADCF-D4D211C5639A"));
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));// join with next

            incoming1.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));
            outgoing1.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));// join with next

            incoming2.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));
            outgoing2.Add(Guid.Parse("19E200DD-965B-4A5D-8F7A-7A3DE6003895"));
            outgoing2.Add(Guid.Parse("53EE5AF4-9560-40BA-9F85-2E586583FDEB"));

            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();
            INotificationReceiver signal1 = new MockINotificationReceiver();
            INotificationReceiver signal2 = new MockINotificationReceiver();

            // processor info
            MockSmartAdapter.MockSmartAdapterInfo adapterinfo0 = new MockSmartAdapter.MockSmartAdapterInfo(incoming0, outgoing0);
            MockSmartAdapter.MockSmartAdapterInfo adapterinfo1 = new MockSmartAdapter.MockSmartAdapterInfo(incoming1, outgoing1);
            MockSmartAdapter.MockSmartAdapterInfo adapterinfo2 = new MockSmartAdapter.MockSmartAdapterInfo(incoming2, outgoing2);


            // change static input property
            adapterinfo0.SetStaticInputs(false);
            adapterinfo1.SetStaticInputs(true);
            adapterinfo2.SetStaticInputs(true);

            adapterinfo0.ID = (uint)1;
            adapterinfo1.ID = (uint)2;
            adapterinfo2.ID = (uint)3;

            adapterinfo0.Name = (String)"SmartAdapter0";
            adapterinfo1.Name = (String)"SmartAdapter1";
            adapterinfo2.Name = (String)"SmartAdapter2";

            adapterinfo0.Receiver = signal0;
            adapterinfo1.Receiver = signal1;
            adapterinfo2.Receiver = signal2;

            // Create Smart Adapters
            ISmartAdapter smartAdapter0 = new MockSmartAdapter(adapterinfo0);
            ISmartAdapter smartAdapter1 = new MockSmartAdapter(adapterinfo1);
            ISmartAdapter smartAdapter2 = new MockSmartAdapter(adapterinfo2);

            // Initialize target
            MockMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);
            AdapterContainer target = new AdapterContainer(bus, adaptercontainerinfo);

            // link chain
            target.Link(smartAdapter1);
            target.Link(smartAdapter2);

            ISet<Guid> subsribeto = new HashSet<Guid>();
            subsribeto.Add(Guid.Parse("19E200DD-965B-4A5D-8F7A-7A3DE6003895"));

            // Registers events
            target.Register();
            bus.TriggerSubscription(subsribeto);

            // extract Guids
            int expected = 1; // all four inputs 
            int actual = bus.Subscribed.Count;

            bus.TriggerUnsubscription(subsribeto);

            // verify status
            Assert.AreEqual(expected, actual);

        }

        /// <summary>
        /// Message bus subscription
        /// Adapters chain: Smart Smart Smart
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void SubscribeChainSmartSmartSmart()
        {
            // Two smart Adapters
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();
            ISet<Guid> incoming1 = new HashSet<Guid>();
            ISet<Guid> outgoing1 = new HashSet<Guid>();
            ISet<Guid> incoming2 = new HashSet<Guid>();
            ISet<Guid> outgoing2 = new HashSet<Guid>();

            // Assign values. Represent first adapter in line with four inputs A,B,C,D
            // Default behaviour for smart adapter return C & D
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            incoming0.Add(Guid.Parse("9AC8D5D8-FF0F-45CA-9C40-7F2CBB8DDBB2"));
            incoming0.Add(Guid.Parse("485A6395-CD79-48FF-9D4E-38B157FD6C5C"));
            incoming0.Add(Guid.Parse("1B9C8891-9BE3-4C4C-ADCF-D4D211C5639A"));
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));// join with next

            incoming1.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));
            outgoing1.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));// join with next

            incoming2.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));
            outgoing2.Add(Guid.Parse("19E200DD-965B-4A5D-8F7A-7A3DE6003895"));
            outgoing2.Add(Guid.Parse("53EE5AF4-9560-40BA-9F85-2E586583FDEB"));

            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();
            INotificationReceiver signal1 = new MockINotificationReceiver();
            INotificationReceiver signal2 = new MockINotificationReceiver();

            // processor info
            MockSmartAdapter.MockSmartAdapterInfo adapterinfo0 = new MockSmartAdapter.MockSmartAdapterInfo(incoming0, outgoing0);
            MockSmartAdapter.MockSmartAdapterInfo adapterinfo1 = new MockSmartAdapter.MockSmartAdapterInfo(incoming1, outgoing1);
            MockSmartAdapter.MockSmartAdapterInfo adapterinfo2 = new MockSmartAdapter.MockSmartAdapterInfo(incoming2, outgoing2);

            // set inputs to true
            adapterinfo0.SetStaticInputs(true);
            adapterinfo1.SetStaticInputs(true);
            adapterinfo2.SetStaticInputs(true);

            adapterinfo0.ID = (uint)1;
            adapterinfo1.ID = (uint)2;
            adapterinfo2.ID = (uint)3;

            adapterinfo0.Name = (String)"SmartAdapter0";
            adapterinfo1.Name = (String)"SmartAdapter1";
            adapterinfo2.Name = (String)"SmartAdapter2";

            adapterinfo0.Receiver = signal0;
            adapterinfo1.Receiver = signal1;
            adapterinfo2.Receiver = signal2;

            // Create Smart Adapters
            ISmartAdapter smartAdapter0 = new MockSmartAdapter(adapterinfo0);
            ISmartAdapter smartAdapter1 = new MockSmartAdapter(adapterinfo1);
            ISmartAdapter smartAdapter2 = new MockSmartAdapter(adapterinfo2);

            // Initialize target
            MockMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);
            AdapterContainer target = new AdapterContainer(bus, adaptercontainerinfo);

            // link chain
            target.Link(smartAdapter1);
            target.Link(smartAdapter2);

            ISet<Guid> subsribeto = new HashSet<Guid>();
            subsribeto.Add(Guid.Parse("19E200DD-965B-4A5D-8F7A-7A3DE6003895"));

            // Registers events 
            target.Register();
            bus.TriggerSubscription(subsribeto);

            // extract Guids
            int expected = 1; // all four inputs 
            int actual = bus.Subscribed.Count;

            bus.TriggerUnsubscription(subsribeto);

            // verify status
            Assert.AreEqual(expected, actual);

        }

        /// <summary>
        /// Message bus subscription
        /// Adapters chain: Smart SmartStaticFalse
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void LinkStaticFalseException()
        {
            // Two smart Adapters
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();
            ISet<Guid> incoming1 = new HashSet<Guid>();
            ISet<Guid> outgoing1 = new HashSet<Guid>();
            ISet<Guid> incoming2 = new HashSet<Guid>();
            ISet<Guid> outgoing2 = new HashSet<Guid>();

            // Assign values. Represent first adapter in line with four inputs A,B,C,D
            // Default behaviour for smart adapter return C & D
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            incoming0.Add(Guid.Parse("9AC8D5D8-FF0F-45CA-9C40-7F2CBB8DDBB2"));
            incoming0.Add(Guid.Parse("485A6395-CD79-48FF-9D4E-38B157FD6C5C"));
            incoming0.Add(Guid.Parse("1B9C8891-9BE3-4C4C-ADCF-D4D211C5639A"));
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));// join with next

            incoming1.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));
            outgoing1.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));
            outgoing1.Add(Guid.Parse("19E200DD-965B-4A5D-8F7A-7A3DE6003895"));

            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();
            INotificationReceiver signal1 = new MockINotificationReceiver();

            // processor info
            MockSmartAdapter.MockSmartAdapterInfo adapterinfo0 = new MockSmartAdapter.MockSmartAdapterInfo(incoming0, outgoing0);
            MockSmartAdapter.MockSmartAdapterInfo adapterinfo1 = new MockSmartAdapter.MockSmartAdapterInfo(incoming1, outgoing1);

            // set inputs to true
            adapterinfo0.SetStaticInputs(true);
            adapterinfo1.SetStaticInputs(false);

            adapterinfo0.ID = (uint)1;
            adapterinfo1.ID = (uint)2;

            adapterinfo0.Name = (String)"SmartAdapter0";
            adapterinfo1.Name = (String)"SmartAdapter1";

            adapterinfo0.Receiver = signal0;
            adapterinfo1.Receiver = signal1;

            // Create Smart Adapters
            ISmartAdapter smartAdapter0 = new MockSmartAdapter(adapterinfo0);
            ISmartAdapter smartAdapter1 = new MockSmartAdapter(adapterinfo1);

            // Initialize target
            MockMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);
            AdapterContainer target = new AdapterContainer(bus, adaptercontainerinfo);

            // link chain
            try
            {
                target.Link(smartAdapter1);
                Assert.IsTrue(false);
            }
            catch (Exception e)
            {
                Assert.IsTrue(true, e.Message);
            }



        }

        /// <summary>
        /// Message bus subscription
        /// Adapters chain: 
        /// Test Info member of AdapterContainer
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void InfoMemberStateTest()
        {
            // Two smart Adapters
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();
            ISet<Guid> incoming1 = new HashSet<Guid>();
            ISet<Guid> outgoing1 = new HashSet<Guid>();

            // Assign values. Represent first adapter in line with four inputs A,B,C,D
            // Default behaviour for smart adapter return C & D
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            incoming0.Add(Guid.Parse("9AC8D5D8-FF0F-45CA-9C40-7F2CBB8DDBB2"));
            incoming0.Add(Guid.Parse("485A6395-CD79-48FF-9D4E-38B157FD6C5C"));
            incoming0.Add(Guid.Parse("1B9C8891-9BE3-4C4C-ADCF-D4D211C5639A"));
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));// join with next

            incoming1.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));
            outgoing1.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));
            outgoing1.Add(Guid.Parse("19E200DD-965B-4A5D-8F7A-7A3DE6003895"));

            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();
            INotificationReceiver signal1 = new MockINotificationReceiver();

            // processor info
            MockSmartAdapter.MockSmartAdapterInfo adapterinfo0 = new MockSmartAdapter.MockSmartAdapterInfo(incoming0, outgoing0);
            MockSmartAdapter.MockSmartAdapterInfo adapterinfo1 = new MockSmartAdapter.MockSmartAdapterInfo(incoming1, outgoing1);

            // set inputs to true
            adapterinfo0.SetStaticInputs(true);
            adapterinfo1.SetStaticInputs(true);

            adapterinfo0.ID = (uint)1;
            adapterinfo1.ID = (uint)2;

            adapterinfo0.Name = (String)"SmartAdapter0";
            adapterinfo1.Name = (String)"SmartAdapter1";

            adapterinfo0.Receiver = signal0;
            adapterinfo1.Receiver = signal1;

            // Create Smart Adapters
            ISmartAdapter smartAdapter0 = new MockSmartAdapter(adapterinfo0);
            ISmartAdapter smartAdapter1 = new MockSmartAdapter(adapterinfo1);

            // Initialize target
            MockMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);
            AdapterContainer target = new AdapterContainer(bus, adaptercontainerinfo);

            // link chain
            target.Link(smartAdapter1);

            ISet<IAdapterInfo> items = new HashSet<IAdapterInfo>();
            items.Add(adapterinfo0);
            items.Add(adapterinfo1);


            ISet<IAdapterInfo> expected = items;
            ISet<IAdapterInfo> actual = target.Info.MemberInfos;

            // Verify existance of second adapter in info object
            Assert.AreEqual(expected.Count, actual.Count);

        }

        /// <summary>
        /// Message bus subscription
        /// Adapters chain: 
        /// Tests unsubscription process for simple adapters
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void UnsubscribeSimpleAdapterEventTest()
        {
            // Two smart Adapters
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();
            ISet<Guid> incoming1 = new HashSet<Guid>();
            ISet<Guid> outgoing1 = new HashSet<Guid>();

            // Assign values. Represent first adapter in line with four inputs A,B,C,D
            // Default behaviour for smart adapter return C & D
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            incoming0.Add(Guid.Parse("9AC8D5D8-FF0F-45CA-9C40-7F2CBB8DDBB2"));
            incoming0.Add(Guid.Parse("485A6395-CD79-48FF-9D4E-38B157FD6C5C"));
            incoming0.Add(Guid.Parse("1B9C8891-9BE3-4C4C-ADCF-D4D211C5639A"));// there are 4 incoming
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));// join with next

            incoming1.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));
            outgoing1.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));
            outgoing1.Add(Guid.Parse("19E200DD-965B-4A5D-8F7A-7A3DE6003895"));

            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();
            INotificationReceiver signal1 = new MockINotificationReceiver();

            // processor info
            IAdapterInfo adapterinfo0 = new MockAdapter.MockAdapterInfo(incoming0, outgoing0);
            IAdapterInfo adapterinfo1 = new MockAdapter.MockAdapterInfo(incoming1, outgoing1);

            adapterinfo0.ID = (uint)1;
            adapterinfo1.ID = (uint)2;

            adapterinfo0.Name = (String)"SimpleAdapter0";
            adapterinfo1.Name = (String)"SimpleAdapter1";

            adapterinfo0.Receiver = signal0;
            adapterinfo1.Receiver = signal1;

            // Create Smart Adapters
            IAdapter smartAdapter0 = new MockAdapter(adapterinfo0);
            IAdapter smartAdapter1 = new MockAdapter(adapterinfo1);

            // Initialize target
            MockMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);
            AdapterContainer target = new AdapterContainer(bus, adaptercontainerinfo);

            // link chain
            target.Link(smartAdapter1);

            target.Register();
            ISet<Guid> subsribeto = new HashSet<Guid>();
            subsribeto.Add(Guid.Parse("19E200DD-965B-4A5D-8F7A-7A3DE6003895"));
            bus.TriggerSubscription(subsribeto);
            // did we subscribe to all 4?
            Assert.AreEqual(4, bus.Subscribed.Count);

            bus.TriggerUnsubscription(subsribeto);

            int expected = 0;
            int actual = bus.Subscribed.Count;
            Assert.AreEqual(expected, actual); // did we unsub?
        }

        [TestMethod]
        [TestCategory("Adaptercontainer")]
        public void UnsubscribeSimpleAdapterWithActivePubsEventTest()
        {
            MockMessageBusProxy bus = new MockMessageBusProxy();
            Guid outtarget = Guid.NewGuid();
            Guid outkeep = Guid.NewGuid();

            ISet<Guid> incomingSIDs = new HashSet<Guid>() { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };
            ISet<Guid> outgoingSIDs = new HashSet<Guid>() { outkeep, outtarget };
            IAdapterInfo info = new MockAdapter.MockAdapterInfo(incomingSIDs, outgoingSIDs);
            IAdapter simpleAdapter = new MockAdapter(info);
            IAdapterContainerInfo containerinfo = new AdapterContainer.AdapterContainerInfo(info);
            AdapterContainer container = new AdapterContainer(bus, containerinfo);
            container.Register();

            // Means someone Downstream is subscribing to both published IDs
            bus.TriggerSubscription(new HashSet<Guid>() { outtarget });

            // Did all three subs go?
            Assert.AreEqual(3, bus.Subscribed.Count);

            // somone else subscribed to outkeep, but never unsubs it...
            bus.ActivePubs.Add(outkeep);
            bus.TriggerSubscription(new HashSet<Guid> { outkeep });
            Assert.AreEqual(3, bus.Subscribed.Count);

            bus.TriggerUnsubscription(new HashSet<Guid> { outtarget });
            // should do nothing, becuase we still have outkeep, and these are dumb (active pubs means there is a subscribtion)
            Assert.AreEqual(3, bus.Subscribed.Count);


        }

        /// <summary>
        /// Message bus subscription
        /// Adapters chain: 
        /// Tests unsubscription process for simple adapters
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void UnsubscribeSmartAdapterEventTest()
        {
            // Two smart Adapters
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();
            ISet<Guid> incoming1 = new HashSet<Guid>();
            ISet<Guid> outgoing1 = new HashSet<Guid>();
            ISet<Guid> incoming2 = new HashSet<Guid>();
            ISet<Guid> outgoing2 = new HashSet<Guid>();

            // Assign values. Represent first adapter in line with four inputs A,B,C,D
            // Default behaviour for smart adapter return C & D
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            incoming0.Add(Guid.Parse("9AC8D5D8-FF0F-45CA-9C40-7F2CBB8DDBB2"));
            incoming0.Add(Guid.Parse("485A6395-CD79-48FF-9D4E-38B157FD6C5C"));
            incoming0.Add(Guid.Parse("1B9C8891-9BE3-4C4C-ADCF-D4D211C5639A"));
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));// join with next

            incoming1.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));
            outgoing1.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));
            outgoing1.Add(Guid.Parse("19E200DD-965B-4A5D-8F7A-7A3DE6003895"));

            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();
            INotificationReceiver signal1 = new MockINotificationReceiver();

            // processor info
            MockSmartAdapter.MockSmartAdapterInfo adapterinfo0 = new MockSmartAdapter.MockSmartAdapterInfo(incoming0, outgoing0);
            MockSmartAdapter.MockSmartAdapterInfo adapterinfo1 = new MockSmartAdapter.MockSmartAdapterInfo(incoming1, outgoing1);

            // static inputs
            adapterinfo0.SetStaticInputs(true);
            adapterinfo1.SetStaticInputs(true);

            adapterinfo0.ID = (uint)1;
            adapterinfo1.ID = (uint)2;

            adapterinfo0.Name = (String)"SimpleAdapter0";
            adapterinfo1.Name = (String)"SimpleAdapter1";

            adapterinfo0.Receiver = signal0;
            adapterinfo1.Receiver = signal1;

            // Create Smart Adapters
            MockSmartAdapter smartAdapter0 = new MockSmartAdapter(adapterinfo0);
            MockSmartAdapter smartAdapter1 = new MockSmartAdapter(adapterinfo1);

            // Initialize target
            MockMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);
            AdapterContainer target = new AdapterContainer(bus, adaptercontainerinfo);

            // link chain
            target.Link(smartAdapter1);

            target.Register();
            ISet<Guid> subsribeto = new HashSet<Guid>();
            subsribeto.Add(Guid.Parse("19E200DD-965B-4A5D-8F7A-7A3DE6003895"));
            bus.TriggerSubscription(subsribeto);
            bus.TriggerUnsubscription(subsribeto);

            int expected = 0;
            int actual = bus.Subscribed.Count;
            Assert.AreEqual(expected, actual);
        }


        /// <summary>
        /// A Test for ActivePubsMultipleSubscriptionTest
        /// Message bus subscription
        /// Smart Smart Smart Adapters
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void ActivePubsMultipleSubscriptionTest()
        {
            // first adapter in chain Guids
            // Abbreviations {A1, I1, 01} {Adapter,Input, Output}
            Guid A1I1 = Guid.Parse("AFAD504B-D48F-46BF-BBE5-F8204E77F17B");
            Guid A1I2 = Guid.Parse("B499DEA7-FE4E-4060-9A12-1B50AE681D87");
            Guid A1I3 = Guid.Parse("CA423E33-AC8F-4D8D-A2FF-DE1F4D9A1182");
            Guid A1I4 = Guid.Parse("0889EFF2-E31E-4583-84F6-B2B1757F1F1D");
            Guid A1O1 = Guid.Parse("D2EC1282-DB01-40BF-9440-59866F7D0EE4");
            Guid A1O2 = Guid.Parse("983C0161-8048-4A3A-956D-7BDD59CDE9D0");

            // second adapter in chain
            // Abbreviations {A2, I2, 02} {Adapter,Input, Output}
            Guid A2O1 = Guid.Parse("9B1C1F50-20DC-4BB2-9C7B-ACFC99A0EA17");
            Guid A2O2 = Guid.Parse("C0DBC1D1-B373-4639-95D5-FEAFCBE992BF");

            // final adapter in chain
            // Abbreviations {A3, I3, 03} {Adapter,Input, Output}
            Guid A3O1 = Guid.Parse("E9FB50FE-ADA8-41CA-9C21-6B3615524104");
            Guid A3O2 = Guid.Parse("91924239-ED49-4CAF-B7D7-AC1335EBF21A");


            // Map for A1 adapter A1Map
            Dictionary<ISet<Guid>, ISet<Guid>> A1Map = new Dictionary<ISet<Guid>, ISet<Guid>>();
            // Map for A2 adapter A2Map
            Dictionary<ISet<Guid>, ISet<Guid>> A2Map = new Dictionary<ISet<Guid>, ISet<Guid>>();
            // Map for A3 adapter A1Map
            Dictionary<ISet<Guid>, ISet<Guid>> A3Map = new Dictionary<ISet<Guid>, ISet<Guid>>();

            // Adapter1
            Guid[] I1 = new Guid[] { A1I1, A1I2 };
            Guid[] I2 = new Guid[] { A1I3, A1I4 };
            Guid[] O1 = new Guid[] { A1O1 };
            Guid[] O2 = new Guid[] { A1O2 };

            A1Map.Add(new HashSet<Guid>(I1), new HashSet<Guid>(O1));
            A1Map.Add(new HashSet<Guid>(I2), new HashSet<Guid>(O2));

            // Adapter 2
            I1 = new Guid[] { A1O1 };
            I2 = new Guid[] { A1O2 };
            O1 = new Guid[] { A2O1 };
            O2 = new Guid[] { A2O2 };

            A2Map.Add(new HashSet<Guid>(I1), new HashSet<Guid>(O1));
            A2Map.Add(new HashSet<Guid>(I2), new HashSet<Guid>(O2));

            // Adapter 3
            I1 = new Guid[] { A2O1 };
            I2 = new Guid[] { A2O2 };
            O1 = new Guid[] { A3O1 };
            O2 = new Guid[] { A3O2 };

            A3Map.Add(new HashSet<Guid>(I1), new HashSet<Guid>(O1));
            A3Map.Add(new HashSet<Guid>(I2), new HashSet<Guid>(O2));

            // Create adapters info by map 
            MockSmartAdapter.MockSmartAdapterInfo AI1 = new MockSmartAdapter.MockSmartAdapterInfo(A1Map);
            MockSmartAdapter.MockSmartAdapterInfo AI2 = new MockSmartAdapter.MockSmartAdapterInfo(A2Map);
            MockSmartAdapter.MockSmartAdapterInfo AI3 = new MockSmartAdapter.MockSmartAdapterInfo(A3Map);



            // Set inputs to test map
            AI1.SetStaticInputs(true);
            AI2.SetStaticInputs(true);
            AI3.SetStaticInputs(true);


            AI1.ID = (uint)1;
            AI2.ID = (uint)2;
            AI3.ID = (uint)3;

            AI1.Name = (String)"SmartAdapter0";
            AI2.Name = (String)"SmartAdapter1";
            AI3.Name = (String)"SmartAdapter2";

            // initialize signals
            // {S1,S2,S3} => {Signal1,Signal2,Signal3}
            INotificationReceiver S1 = new MockINotificationReceiver();
            INotificationReceiver S2 = new MockINotificationReceiver();
            INotificationReceiver S3 = new MockINotificationReceiver();

            AI1.Receiver = S1;
            AI2.Receiver = S2;
            AI3.Receiver = S3;

            // Create Smart Adapters
            // {SA1,SA2,SA3} = {SmartAdapter1,SmartAdapter2,SmartAdapter3}
            ISmartAdapter SA1 = new MockSmartAdapter(AI1);
            ISmartAdapter SA2 = new MockSmartAdapter(AI2);
            ISmartAdapter SA3 = new MockSmartAdapter(AI3);

            // Initialize target
            // {B1,ACI1} => {MessageProxyBus1, AdapterContainer1}
            MockMessageBusProxy B1 = new MockMessageBusProxy();
            IAdapterContainerInfo ACI1 = new AdapterContainer.AdapterContainerInfo(AI1);
            AdapterContainer target = new AdapterContainer(B1, ACI1);

            // link chain
            target.Link(SA2);
            target.Link(SA3);

            // Subscription signal sets
            ISet<Guid> F1 = new HashSet<Guid>();
            ISet<Guid> F2 = new HashSet<Guid>();

            // register all signals
            target.Register();

            ISet<Guid> subscribeto = new HashSet<Guid>();
            ISet<Guid> unsubscribe = new HashSet<Guid>();

            subscribeto.Add(A3O1);
            B1.TriggerSubscription(subscribeto);

            bool expected = true;
            bool actual = true;

            //Case1: Subscription to A3O1 should contain only A1I1 and A1I2 as per map
            actual = (B1.Subscribed.Contains(A1I1) && B1.Subscribed.Contains(A1I2) && B1.Subscribed.Count == 2);
            Assert.AreEqual(actual, expected);

            //Case2: Subscribe to A302 also
            subscribeto.Clear();
            subscribeto.Add(A3O1);
            subscribeto.Add(A3O2);
            B1.TriggerSubscription(subscribeto);
            actual = (B1.Subscribed.Count == 4 && B1.Subscribed.Contains(A1I1) && B1.Subscribed.Contains(A1I2) && B1.Subscribed.Contains(A1I3) && B1.Subscribed.Contains(A1I4));
            Assert.AreEqual(actual, expected);

            //Case3: Subscription to A3O1 & A302, ActivePubs only A301 unsubscribe A302 make sure only A1I1 and A1I2 as per map
            subscribeto.Clear();
            subscribeto.Add(A3O1);
            subscribeto.Add(A3O2);

            unsubscribe = subscribeto;
            B1.TriggerUnsubscription(unsubscribe);

            B1.TriggerSubscription(subscribeto);

            B1.ActivePubs.Add(A3O1);

            unsubscribe.Clear();
            unsubscribe.Add(A3O2);

            B1.TriggerUnsubscription(unsubscribe);
            actual = (B1.Subscribed.Contains(A1I1) && B1.Subscribed.Contains(A1I2) && B1.Subscribed.Count == 2);
            Assert.AreEqual(actual, expected);

        }


        /// <summary>
        /// A Test for Set IDs outgoing and incoming 
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void set_IDsTest()
        {
            // Guid sets
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();

            // Assign values
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));

            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();

            // processor info
            IAdapterInfo adapterinfo0 = new MockAdapter.MockAdapterInfo(incoming0, outgoing0);

            // Initialize Adapter
            adapterinfo0.ID = (uint)1;
            adapterinfo0.Name = (String)"SimpleAdapter0";
            adapterinfo0.Receiver = signal0;

            // Create simple Adapters
            IAdapter simpleAdapter0 = new MockAdapter(adapterinfo0);

            // Initialize target
            AdapterContainer.AdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);

            bool expected = true;
            bool actual = false;
            try
            {
                adaptercontainerinfo.OutgoingStreamIDs = outgoing0;
            }
            catch
            {
                actual = true;
            }
            Assert.AreEqual(expected, actual);
            actual = false;
            try
            {
                adaptercontainerinfo.OutgoingStreamIDs = incoming0;
            }
            catch
            {
                actual = true;
            }
            Assert.AreEqual(expected, actual);

        }

        /// <summary>
        /// A Test for Add Adapter 
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void AddAdapterTest()
        {
            // Two smart Adapters
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();
            ISet<Guid> incoming1 = new HashSet<Guid>();
            ISet<Guid> outgoing1 = new HashSet<Guid>();

            // Assign values
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));// join with next
            incoming1.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));
            outgoing1.Add(Guid.Parse("1C5F575E-AC54-48E2-A4B5-655FAEE5CED9"));


            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();
            INotificationReceiver signal1 = new MockINotificationReceiver();
            INotificationReceiver signal2 = new MockINotificationReceiver();

            // processor info
            IAdapterInfo adapterinfo0 = new MockAdapter.MockAdapterInfo(incoming0, outgoing0);
            IAdapterInfo adapterinfo1 = new MockAdapter.MockAdapterInfo(incoming1, outgoing1);

            adapterinfo0.ID = (uint)1;
            adapterinfo1.ID = (uint)2;

            adapterinfo0.Name = (String)"SimpleAdapter0";
            adapterinfo1.Name = (String)"SimpleAdapter1";

            adapterinfo0.Receiver = signal0;
            adapterinfo1.Receiver = signal1;

            // Create Adapters
            IAdapter simpleAdapter0 = new MockAdapter(adapterinfo0);
            //IAdapter simpleAdapter1 = new MockAdapter(adapterinfo1);


            // Initialize target
            IMessageBusProxy bus = new MockMessageBusProxy();
            IAdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);

            adaptercontainerinfo.AddAdapter(adapterinfo1);

            bool expected = true;
            bool actual = (adaptercontainerinfo.MemberInfos.Count == 2);
            Assert.AreEqual(expected, actual);
              

        }


        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void RuntimeTypeTest()
        {

            // Guid sets
            ISet<Guid> incoming0 = new HashSet<Guid>();
            ISet<Guid> outgoing0 = new HashSet<Guid>();

            // Assign values
            incoming0.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            outgoing0.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));

            // initialize signals
            INotificationReceiver signal0 = new MockINotificationReceiver();

            // processor info
            IAdapterInfo adapterinfo0 = new MockAdapter.MockAdapterInfo(incoming0, outgoing0);

            // Initialize Adapter
            adapterinfo0.ID = (uint)1;
            adapterinfo0.Name = (String)"SimpleAdapter0";
            adapterinfo0.Receiver = signal0;

            // Create simple Adapters
            IAdapter simpleAdapter0 = new MockAdapter(adapterinfo0);

            // Initialize target
            AdapterContainer.AdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo0);


            bool expected = true;
            adaptercontainerinfo.RuntimeType = typeof(AdapterContainer);
            bool actual = (adaptercontainerinfo.RuntimeType == typeof(AdapterContainer));
            Assert.AreEqual(expected, actual);
            actual = false;
            try
            {
                adaptercontainerinfo.RuntimeType = typeof(object);

            }
            catch
            {
                actual = true;
            }
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        /// AdapterContainer ChangeInputs test
        /// </summary>
        [TestMethod]
        [TestCategory("AdapterContainer")]
        public void ChangeInputsTest()
        {
            // Guid sets
            ISet<Guid> incoming = new HashSet<Guid>();
            ISet<Guid> outgoing = new HashSet<Guid>();

            // Assign values
            incoming.Add(Guid.Parse("7C47D697-7563-4137-AAC3-18C87A44EACF"));
            outgoing.Add(Guid.Parse("FBA21A7A-B284-447C-A359-2040F751BD5B"));

            // initialize signals
            INotificationReceiver signal = new MockINotificationReceiver();

            // processor info
            MockSmartAdapter.MockSmartAdapterInfo adapterinfo = new MockSmartAdapter.MockSmartAdapterInfo(incoming, outgoing);

            // Initialize Adapter
            adapterinfo.ID = (uint)1;
            adapterinfo.Name = (String)"SimpleAdapter0";
            adapterinfo.Receiver = signal;

            // Create simple Adapters
            MockSmartAdapter smartAdapter = new MockSmartAdapter(adapterinfo);

            // Initialize target
            AdapterContainer.AdapterContainerInfo adaptercontainerinfo = new AdapterContainer.AdapterContainerInfo(adapterinfo);

            // Initialize target
            MockMessageBusProxy B1 = new MockMessageBusProxy();
            AdapterContainer target = new AdapterContainer(B1, adaptercontainerinfo);

            smartAdapter.ChangeInputs +=smartAdapter_ChangeInputs;
            smartAdapter.OnChangeInputs();

            bool expected = true;

            Assert.AreEqual(expected, eventstatus);

        }

        private void smartAdapter_ChangeInputs(object obj, EventArgs args)
        {
            eventstatus = true;
        }


        #endregion
    }
}
